import redis
import logging
from logging.handlers import RotatingFileHandler


# 配置config类
class Config(object):
    # 配置mysql,新建数据库名为newsinfo
    SQLALCHEMY_DATABASE_URI = "mysql://mintai:123456@192.168.73.128/newsinfo"
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    REDIS_HOST = "192.168.73.128"
    # 配置redis
    REDIS_PORT = 6379

    # 配置session
    SECRET_KEY = "zhangliang"

    SESSION_TYPE = "redis"  # 指定session保存到redis中
    SESSION_USE_SIGNER = True  # 让cookie中的session_id被加密处理
    SESSION_REDIS = redis.StrictRedis(host=REDIS_HOST, port=REDIS_PORT)
    PERMANENT_SESSION_LIFETIME = 86400  # session有效期,单位为秒




class DevelopmentConfig(Config):
    #  工程配置文件,开启Debug
    DEBUG = True

    # 设置日志等级
    LOG_LEVEL = logging.DEBUG


class ProductionConfig(Config):
    #  工程配置文件,关闭Debug
    DEBUG = False
    # 设置日志等级
    LOG_LEVEL = level=logging.ERROR
